package com.clearance.mine_clearance.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.clearance.mine_clearance.entry.BetInfo;
import com.clearance.mine_clearance.entry.Result;
import com.clearance.mine_clearance.entry.dto.BetInfoDto;
import com.clearance.mine_clearance.entry.dto.RedPacketDto;
import com.clearance.mine_clearance.entry.vo.BetInfoVo;
import com.clearance.mine_clearance.mapper.BetInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin("*")
@RestController
@RequestMapping("/mine/betInfo")
public class BetInfoController {

    @Autowired
    private BetInfoMapper betInfoMapper;

    @PostMapping("/selectPage")
    public Result selectPage(@RequestBody BetInfoVo betInfoVo){
        if(betInfoVo.getCurrent()==0){
            betInfoVo.setCurrent(1);
        }
        int firstIndex = (betInfoVo.getCurrent()-1) * betInfoVo.getSize();
        //到第几条数据结束
        int lastIndex = betInfoVo.getCurrent() * betInfoVo.getSize();
        betInfoVo.setCurrent(firstIndex);
        betInfoVo.setSize(lastIndex);
        Integer count = betInfoMapper.count(betInfoVo);
        List<BetInfoDto> betInfoList = betInfoMapper.selectPage(betInfoVo);
        Map<String, Object> result = new HashMap<>();
        result.put("count",count);
        result.put("BetInfoList",betInfoList);
        return new Result<Map<String, Object>>().success(result);
    }
}




















